package com.atstudy.list;

import java.util.ArrayList;
import java.util.List;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/1/3 9:44
 * @copyright: 博为峰
 */
public class ListDemo {
    public static void main(String[] args) {
//        m1();
//        m2();
//        m3();
        List list = new ArrayList();//多态
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        System.out.println(list.get(1));//b
        System.out.println(list.indexOf("b"));
        System.out.println(list.lastIndexOf("b"));
    }

    private static void m3() {
        List list = new ArrayList();//多态
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.set(1, "B");//[a, B, c]
        System.out.println(list);
    }

    //删
    private static void m2() {
        List list = new ArrayList();//多态
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.add(1, "d");//[a, d, b, c]
        list.remove(1);//[a, b, c]
        System.out.println(list);
    }

    //增
    private static void m1() {
        List list = new ArrayList();//多态
        list.add("a");
        list.add("b");
        list.add("c");//[a, b, c]
        list.add(1, "d");//[a, d, b, c]
        System.out.println(list);
    }
}
